module.exports = {
  getAllFlag (btbItem) {
    return {
      // 这里主要搞混合不同时间的
      // 是否有信号
      isMinute15HasEmaInfo: this.hasEmaInfo(btbItem, 'minute15EmaInfo'),
      isHourHasEmaInfo: this.hasEmaInfo(btbItem, 'hourEmaInfo'),
      isHour4HasEmaInfo: this.hasEmaInfo(btbItem, 'hour4EmaInfo'),
      isDayHasEmaInfo: this.hasEmaInfo(btbItem, 'dayEmaInfo'),
      isWeekHasEmaInfo: this.hasEmaInfo(btbItem, 'weekEmaInfo'),
      isMonthHasEmaInfo: this.hasEmaInfo(btbItem, 'monthEmaInfo'),
      // 其他
      isHourAndHour4SgOK: this.isHourAndHour4SgOK(btbItem),
      isNewIndex: this.isNewIndex(btbItem)
    }
  },
  isHourAndHour4SgOK (btbItem) {
    const hourEmaInfo = btbItem.hourEmaInfo || {}
    const hour4EmaInfo = btbItem.hour4EmaInfo || {}
    return hourEmaInfo.sg > 0.8 && hour4EmaInfo.sg > 0.5
  },
  // 新上市
  isNewIndex (btbItem) {
    const dayEmaInfo = btbItem.dayEmaInfo || {}
    const weekEmaInfo = btbItem.weekEmaInfo || {}
    if (dayEmaInfo.emInfoList.length > 7) {
      return false
    }
    if (weekEmaInfo.macd && (weekEmaInfo.isMacdIncrease || weekEmaInfo.isMacdDecline)) {
      return false
    }
    return true
  },
  hasEmaInfo (btbItem, key) {
    const emaInfo = btbItem[key] || {}
    return emaInfo.kdjDiff && emaInfo.macd && (emaInfo.isMacdIncrease || emaInfo.isMacdDecline)
  }
}
